/*******************************************************************************
 * Witz - Winboard Chess Engine                                                *
 * DATA.H                                                                      *
 *                                                                             *
 * Defines external linkage of important global variables in each module.      *
 *                                                                             *
 * Please refer to the licence notice in MAIN.C                                *
 *                                                                             *
 * Copywright (C) 2006 Pradu Kannan                                            *
 * http://witz.sf.net/                                                         *
 ******************************************************************************/

#ifndef __data
#define __data

//BOARD.C
extern board newBoard, mainboard, searchHistory[], gameHistory[];
extern int depth, compside;
extern U16 gamedepth, initialMoveNumber;
extern bool useBook;

//CONFIG.C
extern U32 TT_SIZE;
extern char configPath[512];
extern bool hasBook;
extern char bookPath[2048];
extern int gamesWeight, winsWeight;
extern int searchType;
extern bool checkEvasions, recaptureExtensions;
extern double ICS_PV;

//DATABASEGEN.C
extern U64 toBit[64], toBitL90[64], toBitL45[64], toBitR45[64];
extern U64 rankshift[64], fileshift[64], a1h8shift[64], h1a8shift[64];
extern U64 rankmoves[64][256], filemoves[64][256], a1h8moves[64][256], h1a8moves[64][256];
extern U64 Pmoves[2][64], Pcaps[2][64], Kmoves[64], Nmoves[64];
extern U64 plus1[64], plus7[64], plus8[64], plus9[64];
extern U64 minus1[64], minus7[64], minus8[64], minus9[64];
extern U64 ray[64][64][256];
extern char LogTable[65536];
extern char population[65536];
extern U64 zobrist[2][NUMPIECETYPES][64];
extern U64 zobristCastling[2][2];
extern U64 zobristEP[64];
extern char castlnigShift[2];
extern char castlingPrivilageShift[2];
extern int doubleMove[2];
extern int doubleMove2[2];
extern int pawnEPset[2];
extern int signSide[2];
extern U64 rank7[2];
extern move castlingMoves[2];
extern char castlingAnds[2];
extern U64  castlingXors[2][2][2];
extern U64 castlingRotatedXors[2][2][4];
extern char castlingSquaresK[2][2][2];
extern char castlingSquaresR[2][2][2];
extern char castlingBits[2][2];
extern char notCastlingBits[2][2];
extern char castlingQRookFrom[2];
extern char castlingKRookFrom[2];
extern char allCastlingBitsSide[2];
extern char notAllCastlingBitsSide[2];
extern U64 castlingPassover[2][2];
extern U64 castlingEmptySquares[2][2];
extern char* sideToStr[3];
extern char* winToStr[2];
extern char pieceToStr[NUMPIECETYPES];
extern char flip[64];
extern U64 kingStopsWHITEPasser[64][2];
extern U64 kingStopsBLACKPasser[64][2];
extern int distance[64][64];

//EVAL.C
extern int Pval, Nval, Bval, Rval, Qval, Kval;
extern int MOB_WEIGHT, CAPTURE_BONUS, KS_WEIGHT;
extern float KS_SUM;
extern int KS_ScaleStart;
extern int KS_ScaleEnd;
extern int PieceVal[NUMPIECETYPES];
extern int passedPawnPST[64];
extern int default_passedPawnPST[64];
extern int halfpassedPawnPST[64];
extern int default_halfpassedPawnPST[64];
extern int doubledPawnPST[64];
extern int default_doubledPawnPST[64];
extern int isolatedPawnPST[64];
extern int default_isolatedPawnPST[64];
extern int notDefendablePawnPST[64];
extern int default_notDefendablePawnPST[64];

//THREADS.C
extern int NO_PROCESSORS;
extern int sti;
extern bool threaded;

//HASH.C
extern TTentry *TT;

//MAIN.C
extern char currentDir[1024];
extern bool openedInConsole;
extern char* dumpFileLocationPointer;

//MOVEGEN.C
extern moveList mainMoveList;

//MOVEORDERING.C
extern int hh[64][64];
extern move killers[MAX_PLY];

//PST.C
extern int pieceSquare[2][7][64];

//SEARCH.C
extern int depthLimit;
extern U64 nodes;
extern U64 leafNodes;
extern char searchFlag;

//SEE.C
extern U8 (*occupancy[64][64])(const board* pos, const char square);
extern char SEEdir[64][64][256];
extern char SEEpiece[64][64];

//TIMEMANAGER.C
extern int timeLimit;
extern int timeLeft;
extern int timeInc;
extern int movesInitial;
extern int movesLeft;
extern int endTime;
extern int startTime;

//WINBOARD.C
extern bool Ponder;
extern bool Post;
extern bool ICS;

#endif

